-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only use KEYBOARD.COK when it is available, otherwise use embedded table #322
Conversation
src/harness/harness.c
Outdated
'z', /* KEY_Y */ | ||
'y', /* KEY_Z */ | ||
'^', /* KEY_GRAVE */ | ||
-0x21, /* KEY_MINUS */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it supposed to be -0x21
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a German Eszett (ẞ).
>>> b'\xdf'.decode("windows-1252")
'ß'
The binary really contains FFFFFFDFh
.
I think their compiler treated characters as signed ==> the 8-bit 0xdf
value is negative and must be sign-extended to a 32-bit integer.
I think the Carma devs had the source file(s) containing this ascii table in the windows-1252 codepage.
This is of course unwanted by us, and we don't want to encode the Eszett as utf-8. So I think we should just hardcode 0xdf
here and add an extra comment (that can use utf-8).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The German DOS version contains the same codes, but they are all positive there.
So it looks like this is an oversight/bug of OG.
The text input behavior of German Dethrace and the German DOS version is now the same.
I didn't verify the German Windows executable.
src/harness/harness.c
Outdated
@@ -36,49 +36,884 @@ tHarness_game_config harness_game_config; | |||
// Platform hooks | |||
tHarness_platform gHarness_platform; | |||
|
|||
/* clang-format off */ | |||
// Carmgeddon ASCII codes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about putting these tables in a separate file like ascii_tables.h
to avoid adding all this data to the code file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did something similar with sdl2_scancode_to_dinput.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created a ascii_tables.h
header.
…to avoid out-of-bounds texture access
@@ -403,13 +403,15 @@ int AddRollingLetter(char pChar, int pX, int pY, tRolling_type rolling_type) { | |||
let->current_offset = (gCurrent_graf_data->save_slot_letter_height * let->number_of_letters); | |||
for (i = 0; i < let->number_of_letters; i++) { | |||
if (rolling_type == eRT_numeric) { | |||
let->letters[i] = pChar; | |||
/* The (tU8) cast makes sure extended ASCII is positive. */ | |||
let->letters[i] = (tU8)pChar; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done in the German Carmageddon DOS executable.
This makes sure the extended ASCII codes remain positive.
Before, these became negative here.
Not doing this causes an out-of-bounds access when reading the texture of an extended ASCII character.
@@ -0,0 +1,893 @@ | |||
#ifndef DETHRACE_ASCII_TABLES_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file was generated with the attached python script + json files: ascii-codegen.zip
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice change!
'z', /* KEY_Y */ | ||
'y', /* KEY_Z */ | ||
'^', /* KEY_GRAVE */ | ||
0xdf, /* KEY_MINUS (ß) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't verify the actual textures. So there might be cases where the character in the comments does not match the actual glyph present in the texture.
KEYBOARD.TOK
from the steam/gog releaseKEY_xxx
KEY_SHIFT_LSHIFT
withKEY_SHIFT_ANY
Because of this, Holding down SHIFT makes key repeat go crazy quick #321 is triggered with both shift keys.
Fixes #315